﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Cityswitch.aspx.cs" Inherits="Html5.Cityswitch" %>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
    <title>切换城市</title>
    <link type="text/css" rel="stylesheet" href="css/style.css" />
    <link type="text/css" rel="stylesheet" href="css/home.css?v=2016082433" />
    <link href="css/sweetalert.css" rel="stylesheet" />
    <link type="text/css" rel="stylesheet" href="css/page.css?v=1" />
    <style type="text/css">
        .hotcities .cur_city {
            padding-left: 15px;
            margin-right: 15px;
            background: url(../images/link-ico.png) right center no-repeat;
            position: relative;
            height: 34px;
            line-height: 34px;
            border-bottom: none;
        }
    </style>

    <script src="javascript/jquery.js"></script>




</head>
<body>
    <form id="form1" runat="server">
        <div class="page">

            <div id="page_title">
                <h1>切换城市</h1>
            </div>
            <div class="container ">
                <div class="hotcities">
                    <div style="border-bottom: #eaeaea 1px solid;">
                        <p class="cur_city" onclick="setcity()" >当前定位城市：<a href="javascript:" style="color: red; font-size: 14px;" id="mycity"></a></p>

                    </div>


                    <p style="line-height: 28px; background-color: #f9f9f9;">热门城市</p>

                    <select runat="server" id="ddlcity" style="display: none;">
                    </select>

                    <div class="cityitem">

                        <asp:Repeater ID="rptCtiy" runat="server">
                            <ItemTemplate>
                                <a href="javascript:" onclick="selcity(<%#Eval("cid")%>,'<%#Eval("cname")%>')"><%# Eval("cname") %></a>
                            </ItemTemplate>
                        </asp:Repeater>

                    </div>
                    <div class="clear"></div>

                    <p style="line-height: 28px; background-color: #f9f9f9;">全部城市</p>



                    <asp:Repeater ID="rptcity1" runat="server">
                        <ItemTemplate>
                            <p style="line-height: 28px; background-color: #f9f9f9; "><%# Eval("firstletter").ToString().ToUpper() %></p>
                            <div class="cityitem">
                                <asp:Repeater ID="rptCityJunior" runat="server" DataSource='<%#Eval("citylist")%>'>
                                    <ItemTemplate>
                                        <a href="javascript:" onclick="selcity(<%#Eval("cid")%>,'<%#Eval("cname")%>')"><%# Eval("cname") %></a>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </div>

                            <div class="clear"></div>

                        </ItemTemplate>
                    </asp:Repeater>








                </div>
            </div>
        </div>
    </form>
</body>
</html>
<script src="javascript/jCommon.js"></script>
<script src="javascript/sweetalert.min.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=fMnzyhYs0D1cBEl5iGMQ0Dlg"></script>
<script type="text/javascript">
    function selcity(cid, cname) {
        handlecookie("user_cityid", cid, { expires: 365, path: "/", secure: false });
        gourl("/index.aspx?change=1")
        return false;

    }

    function initialize() {

        cityName = "请稍后";
        function myFun(result) {
            cityName = result.name.replace("市", "");
            $("#mycity").html(cityName);
        }
        var myCity = new BMap.LocalCity();
        myCity.get(myFun);
    }

    $(function () {
        initialize();
    });


    //根据定位，选中城市
    function setcity() {
        var mycity = $.trim($("#mycity").html().replace("市", ""));
        if (mycity.length == 0) {

            swal({
                title: "温馨提示",
                text: "正在定位，请稍后",
                type: "warning"
            });
        }
        else {

            var isSuccess = false;

            $("#ddlcity option").each(function () {
                if (mycity.indexOf($(this).text()) >= 0) {
                    isSuccess = true;

                    selcity($("#ddlcity").val(), $("#ddlcity option:selected").text());

                    return;
                }
            });

            if (!isSuccess) {
                swal({
                    title: "温馨提示",
                    text: "此城市尚未开通，你可以直接联系我们 8811000",
                    type: "warning"
                });
            }


        }
    }
</script>
